package com.zks.nio;

import org.junit.Test;

import java.nio.IntBuffer;
import java.security.SecureRandom;

public class BufferTest {
    @Test
    public void testOne(){
        IntBuffer buffer=IntBuffer.allocate(10);
        System.out.println(buffer.capacity());
        for(int i=0;i<buffer.capacity();i++){
            int random=new  SecureRandom().nextInt(20);
            buffer.put(random);

        }
        //由写模式切换为读模式
        buffer.flip();
        while(buffer.hasRemaining()){
            System.out.println(buffer.get());
        }
    }
}
